feat(#466): Resource 增加 LastDiscoverStatus 字段,实现扫描状态追踪#484
Merged
Conversation
added 2 commits
May 20, 2026 17:31
为资源实体新增LastDiscoverStatus字段,支持记录每次扫描的资源状态差异,包括新增/更新/恢复/缺失/未变更五种状态,完善扫描结果统计和数据溯源能力。 主要改动: 1. 新增数据库迁移脚本,添加f_last_discover_status字段 2. 扩展Resource结构体和相关接口,新增扫描状态枚举和更新方法 3. 实现扫描处理器的状态标记逻辑,在table/index/fileset扫描流程中接入状态追踪 4. 补充单元测试覆盖核心场景 5. 调整存储层实现支持新字段的读写
1. 移除冗余的setDiscoverStatusAfterEnrich辅助函数,直接内联调用discoverStatusAfterEnrich 2. 合并Update和UpdateWithDiscoverStatus接口为单个Update方法,自动根据资源字段决定是否更新发现状态 3. 更新所有调用处和测试用例适配新的接口逻辑 4. 调整单元测试验证资源发现状态正确保留
Flynn-Zh
approved these changes
May 20, 2026
1. 重构包结构与依赖注入,将驱动适配器统一封装到logics层全局变量 2. 移除冗余的worker单例实现,合并任务处理逻辑 3. 添加DEBUG_MODE环境变量支持,调试模式下使用本地队列处理发现任务 4. 修复包名错误,统一代码风格与接口调用方式 5. 简化Asynq客户端/服务端创建逻辑,移除不必要的context参数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
What Changed
LastDiscoverStatus字段,记录最近一次扫描的差异状态(新增 / 更新 / 恢复 / 缺失 / 未变更)f_last_discover_status列(dm8 + mariadb 均覆盖)discover_handler.go(-668 行)为discover_table.go/discover_index.go/discover_fileset.go/discover_status.go四个文件,在各扫描流程中接入状态标记Update与UpdateWithDiscoverStatus为单一Update方法,根据资源字段自动决定是否更新发现状态resource_service_test.go/discover_handler_test.go单元测试Why
discover_handler.go单文件达 600+ 行,table / index / fileset 三类扫描混在一起,难以维护How
discover_status.go集中定义状态枚举与discoverStatusAfterEnrich计算逻辑LastDiscoverStatus;Update内部根据字段是否非空判定是否一并更新状态列discover_handler.go删除f_last_discover_status列(默认 NULL,向后兼容)Update接口签名收敛:UpdateWithDiscoverStatus已合并入Update,外部调用方需切换Testing
resource_service_test.go、discover_handler_test.go)Test notes:单测覆盖 Update 在含/不含 discover status 字段两种调用形态下的行为,以及五种状态枚举的标记路径。
Risk & Rollback
Update合并后,如果调用方原本依赖"不更新 discover status"的旧 Update 行为,需要核对字段是否被意外携带ff7de8b3、a4cb3a81ALTER TABLE ... DROP COLUMN f_last_discover_status(脚本均为加列,回滚安全)Additional Notes
adp/vega/vega-backend/docs/pr-a-resource-last-discover-status-plan.mdff7de8b3feat(vega-backend): 实现资源扫描状态追踪能力a4cb3a81refactor(resource): simplify discover status update logic